const { app, pool } = require('./connect')
const user = require('./router/user')
const score = require('./router/score')
const comment = require('./router/comment')
app.all('*', (req, res, next) => {
  //这里处理全局拦截，一定要写在最上面
  next()
})
app.get('/', (req, res) => {  //首页路由
  res.sendFile(__dirname + '/' + 'index.html')
})
app.all('/', (req, res) => {
  pool.getConnection((err, conn) => {
    res.json({ type: 'test' })
    pool.releaseConnection(conn) // 释放连接池，等待别的连接使用
  })
})
app.use('/user', user)
app.use('/score', score)
app.use('/comment', comment)
app.listen(8088, () => {
  console.log('服务启动', 'localhost:8088')
})